<?php
add_action('wp_ajax_nopriv_mostrar_idea', 'mostrar_idea_ajax');
add_action('wp_ajax_mostrar_idea', 'mostrar_idea_ajax');

function mostrar_idea_ajax($id) {
    if ($_POST['id']) {
        $id = $_POST['id'];
    }
    query_posts("p=" . $id);
    ?>
    <?php if (have_posts()): the_post(); ?>
        <h3><?php the_title(); ?></h3>
        <hr class="hr1" />
        <div class="imagen-idea">
            <?php
            if (get_the_post_thumbnail()) {
                $image_id = get_post_thumbnail_id();
                $image_attributes = wp_get_attachment_image_src($image_id, 'full');
                ?>
                <img src="<?php echo $image_attributes[0]; ?>" width="100%" style="min-height: 100px;">
            <?php } else { ?>
                <img src="<?php bloginfo('template_url') ?>/images/no-imagen.jpg" style="width: 580px; height: 320px;">
            <?php } ?>

        </div>

        <div class="descripcion-idea">
            <?php echo excerpt(50); ?>
        </div>
        <a href="/?cat=5" class="boton-comprar">CONSULTAR</a>
        <?php
    endif;

    die();
}
?>
